

var input_title = new Array(100);
function loadlanguage()
{
	var tran = document.getElementsByTagName("span");
	for (var i = 0; i < tran.length; i++)
	{	
		if (tran[i].title == "symbol")
		{
			tran[i].innerHTML = translator(tran[i].innerHTML);
			tran[i].title = "";
		}
	}
	
	var opt = document.getElementsByTagName("option");
	for (var i = 0; i < opt.length; i++)
	{	
		if (opt[i].title == "symbol")
		{
			opt[i].text = translator(opt[i].text);
			opt[i].title = "";
		}
	}
	
	var input = document.getElementsByTagName("input");
	for (var i = 0; i < input.length; i++)
	{	
		if((input[i].type == "button" || input[i].type == "submit") && input[i].title == "symbol")
		{
			input[i].value = translator(input[i].value);
			input[i].title = "";
		}
	}
}

function loadvalue()
{
	var input=document.getElementsByTagName("input");
	for (var i = 0; i < input.length; i++)
	{
		input_title[i]=input[i].title;
		title = input[i].title.split(",");
		if(title[0]=="param")
		{
			if(input[i].type=="text" || input[i].type=="password")
				eval("input["+i+"].value="+input[i].name);
			else if(input[i].type=="hidden")
			{
				eval("input["+i+"].value="+input[i].name);
				if(eval("typeof(input["+(i+1)+"])")!="undefined")
				{
					if(input[i+1].type=="checkbox")
					{
						if(input[i].value=="0")
							input[i+1].checked=0;
						else
							input[i+1].checked=1;
					}
				}
			}
			else if(input[i].type=="radio")
			{
				eval("value="+input[i].name);
				if (input[i].value == value)
				{
					input[i].checked = true;
				}
			}
			input[i].title="";
		}
	}
	var input=document.getElementsByTagName("select");
	for (var i = 0; i < input.length; i++)
	{
		title = input[i].title.split(",");
		if(title[0]=="param")
		{
			eval("value="+input[i].name);
			for (j = 0; j < input[i].length; j ++)
			{			
				if (input[i].options[j].value == value)
				{
					input[i].options[j].selected = true;
					break;
				}
			}
			input[i].title="";
		}
	}
	var input=document.getElementsByTagName("span");
	for (var i = 0; i < input.length; i++)
	{	
		title = input[i].title.split(",");
		if(title[0]=="param")
		{
			if(eval("typeof("+input[i].innerHTML+")")!="undefined")
			{
				eval("value="+input[i].innerHTML);
				input[i].innerHTML=value;
				input[i].innerHTML=unescape(input[i].innerHTML);
			}
			input[i].title="";
		}
	}
	return 0;
}

function receiveparam()
{
	if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
	{
		eval(XMLHttpRequestObject.responseText);
		if(typeof(receivedone)=="function")
			receivedone();
		loadvalue();
		if(typeof(loadvaluedone)=="function")
			loadvaluedone();			
	}
}

function updatecheck(inputName, checkbox)
{
	if (checkbox.checked)
		inputName.value = "1";
	else
		inputName.value = "0";
}

function updatecheckById(Id, checkbox)
{
	if (checkbox.checked)
		document.getElementById(Id).value = "1";
	else
		document.getElementById(Id).value = "0";
}


function checkInString(instr){
	for (i = 0; i < instr.value.length; i++){
        c = instr.value.charAt(i);
        if (c == '"' || c == '\'' || c == '<' || c == '>' || c == '&')
        {
          alert(translator("you_have_used_invalid_characters_sh"));
          instr.focus();
          instr.select();
          return -1;
        }
    }

   return 0;
}

function checkFilenameString(instr){
  for (i = 0; i < instr.value.length; i++){
    c = instr.value.charAt(i);
    if (c == '"' || c == '\'' || c == '<' || c == '>' || c == '/' || c == ':' || c == '*' || c == '.' || c == '?' || c == '|' || c == '\\' || c == '&')
    {
       alert(translator("you_have_used_invalid_characters_lg"));
       instr.focus();
       instr.select();
       return -1;
    }
  }
  return 0;
}

function checkInSpace(instr){
	for (i = 0; i < instr.value.length; i++){
        c = instr.value.charAt(i);
        if (c == ' ')
        {
          alert(translator("space_is_invalid"));
          instr.focus();
          instr.select();
          return -1;
        }
    }

   return 0;
}

function checkIPaddr(input)
{
	var filter=/\d+\.\d+\.\d+\.\d+/;
	if (!filter.test(input.value)){
		alert(translator("please_enter_a_valid_ip_address"));
		input.focus();
		input.select();
		return -1;
	}
	input.value = input.value.match(filter)[0];
	subip = input.value.split(".");
	for (i = 0; i < subip.length; i ++)
	{
		if ((parseInt(subip[i]) > 255) || (parseInt(subip[i]) < 0 ))
		{
			alert(translator("please_enter_a_valid_ip_address"));
			input.focus();
			input.select();
			return -1;
		}
	}	

	// special case for IP="0.0.0.0" && not enabled
	// for example, PPPoE connection failed and tries to change RTSP port
	if (input.disabled) 
		return 0;

	if ((parseInt(subip[0]) == 0) && (parseInt(subip[1]) == 0) && (parseInt(subip[2]) == 0) && (parseInt(subip[3]) == 0))
	{
		alert(translator("please_enter_a_valid_ip_address"));
		input.focus();
		input.select();
		return -1;
	}
	
	return 0;
}

function checkMultiCastIPaddr(input)
{
	var filter=/\d+\.\d+\.\d+\.\d+/;
	if (!filter.test(input.value)){
		alert(translator("please_enter_a_valid_ip_address"));
		input.focus();
		input.select();
		return -1;
	}
	input.value = input.value.match(filter)[0];
	subip = input.value.split(".");
	if ((parseInt(subip[0]) > 239) || (parseInt(subip[0]) < 224 ))
	{
			alert(translator("please_enter_a_valid_ip_address"));
			input.focus();
			input.select();
			return -1;
	}
	for (i = 1; i < subip.length; i ++)
	{
		if ((parseInt(subip[i]) > 255) || (parseInt(subip[i]) < 0 ))
		{
			alert(translator("please_enter_a_valid_ip_address"));
			input.focus();
			input.select();
			return -1;
		}
	}	
	return 0;
}

function checkPort(thisObj)
{
	switch(thisObj.name)
	{
		case "network_http_port":
			defaultPort=80;
			message="http_port_must_be_80_or_from_1025_to_65535";
			break;
		case "network_http_alternateport":
			defaultPort=8080;
			message="secondary_http_port_must_be_from_1025_to_65535";
			break;
		case "network_ftp_port":
			defaultPort=21;
			message="ftp_port_must_be_21_or_from_1025_to_65535";
			break;
		case "network_rtsp_port":
			defaultPort=554;
			message="rtsp_port_must_be_554_or_from_1025_to_65535";
			break;	
		case "network_rtp_videoport":
			defaultPort=5556;
			message="rtp_video_port_must_be_from_1025_to_65535";
			break;	
		case "network_rtp_audioport":
			defaultPort=5558;
			message="rtp_audio_port_must_be_from_1025_to_65535";
			break;	
		case "network_rtsp_s0_multicast_videoport":
			defaultPort=5556;
			message="rtsp_s0_multicast_video_port_must_be_from_1025_to_65535";
			break;		
		case "network_rtsp_s0_multicast_audioport":
			defaultPort=5558;
			message="rtsp_s0_multicast_audio_port_must_be_from_1025_to_65535";
			break;	
		case "network_rtsp_s1_multicast_videoport":
			defaultPort=5556;
			message="rtsp_s1_multicast_video_port_must_be_from_1025_to_65535";
			break;	
		case "network_rtsp_s1_multicast_audioport":
			defaultPort=5558;
			message="rtsp_s1_multicast_audio_port_must_be_from_1025_to_65535";
			break;
		case "syslog_serverport":
			defaultPort=514;
			message="syslog_server_port_must_be_514_or_from_1025_to_65535";
			break;
	}
	if (thisObj.value == defaultPort)
		return 0;
	if ((thisObj.value > 1024) && (thisObj.value <= 65535))
		return 0;
	alert(translator(message));
	thisObj.select();
	thisObj.focus();
	return -1;
}

function checkPassword(Pass1, Pass2)
{
    var vPass1 = Pass1.value;
    var vPass2 = Pass2.value;

    for (i = 0; i < vPass1.length; i++){
        c = vPass1.charAt(i);
        if (!( (c>='@' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || c=="!" ||
               c=="$" || c=="%" || c=="'" || c=="-" || c=="." || c=="^" || c=="_" || c=="~"))
        {
          alert(translator("you_have_used_invalid_characters_passwd"));
          Pass1.focus();
          Pass1.select();
          return -1;
        }
    }

    if (vPass1 != vPass2){
        alert(translator("the_confirm_password_differs_from_the_password"));
        Pass1.focus();
        Pass1.select();
        return -1;
    }
    return 0;
}

function checkemail(input)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(input.value))
		return 0;
	else{
		alert(translator("please_input_a_valid_email_address"));
		input.focus();
		input.select();
		return -1;
	}
}

function checkNumRange(thisObj, up, down)
{
	if ((thisObj.value >= down) && (thisObj.value <= up) && parseInt(thisObj.value)==parseFloat(thisObj.value))
		return 0;
	alert(translator("please_input_a_valid_value") + "[" + down + "," + up + "]");
	thisObj.select();
	thisObj.focus();
	return -1;
}

function checkHHMM(input)
{
	var filter=/\d\d:\d\d/;
	if (!filter.test(input.value)){
		alert(translator("please_enter_a_valid_time"));
		input.focus();
		input.select();
		return -1;
	}
	input.value = input.value.match(filter)[0];
	sub_item = input.value.split(":");
	if (((parseInt(sub_item[0],10) >= 24) || (parseInt(sub_item[1],10) >= 60)) && ((parseInt(sub_item[0],10) != 24) || (parseInt(sub_item[1],10) != 00)))
	{
		alert(translator("please_enter_a_valid_time"));
		input.focus();
		input.select();
		return -1;
	}
	
	return 0;
}

function checkStringSize(input)
{
	len=0;
	for(i=0; (i<input.value.length) && (len<input.maxLength); i++)
		if(input.value.charCodeAt(i)<0x80)
			len+=1;
		else if(input.value.charCodeAt(i)<0x800)
			len+=2;
		else if(input.value.charCodeAt(i)<0x10000)
			len+=3;
		else if(input.value.charCodeAt(i)<0x200000)
			len+=4;
		else if(input.value.charCodeAt(i)<0x4000000)
			len+=5;
		else
			len+=6;
	if(len>input.maxLength)
		i--;
	input.value=input.value.substring(0,i);
}

function checkvalue()
{
	var input=document.getElementsByTagName("input");
	for (var i = 0; i < input.length; i++)
	{	
		if(input[i].value=="")
			continue;
		title = input_title[i].split(",");
		if(title[0]=="param")
		{
			if(input[i].type=="text" || input[i].type=="password")
			{
				if(title[1]=="string")
				{
					checkStringSize(input[i]);
					if(checkInString(input[i]))
						return -1;
					if(title[2]=="space")
					{
						if(checkInSpace(input[i]))
							return -1;
					}
				}
				else if(title[1]=="filename")
				{
					if(checkFilenameString(input[i]))
						return -1;
				}
				else if(title[1]=="ipaddr")
				{
					if(checkIPaddr(input[i]))
						return -1;
				}
				else if(title[1]=="multicastipaddr")
				{
					if(checkMultiCastIPaddr(input[i]))
						return -1;
				}
				else if(title[1]=="port")
				{
					if(checkPort(input[i]))
						return -1;
				}
				else if(title[1]=="email")
				{
					if(checkemail(input[i]))
						return -1;
				}
				else if(title[1]=="num")
				{
					if(checkNumRange(input[i], parseInt(title[2]), parseInt(title[3])))
						return -1;
				}
				else if(title[1]=="time")
				{
					if(checkHHMM(input[i]))
						return -1;
				}
			}
		}
	}
	return 0;
}

function getCookie(Name) 
{
  var search = Name + "="
  if (document.cookie.length > 0) { 
      // if there are any cookies
      offset = document.cookie.indexOf(search)
      if (offset != -1) { 
          // if cookie exists
          offset += search.length

          // set index of beginning of value
          end = document.cookie.indexOf(";", offset)

          // set index of end of cookie value
          if (end == -1)
              end = document.cookie.length

          return unescape(document.cookie.substring(offset, end))
      }
  }
  return 0;
}

function setCookie(name, value, expire) 
{
	strCookie = name + "=" + escape(value);
	if (expire)
	    strCookie += "; expires=" + expire.toGMTString();
	
  document.cookie = strCookie;
}

function translator(str)
{
	var textNode = xmlDoc.getElementsByTagName(str)[lan].childNodes[0];
	
	if (textNode != undefined)
	{
		return textNode.nodeValue;
	}
	else
	{	
		return "";
	}
}

function updateDynSelOpt(x, aList)
{
	var cnt;

	cnt = 0;
	for (i = 0; i < aList.length; i ++) {

		if (aList[i][0])	cnt ++;
	}
	
	if (cnt != 0) {
		x.length = cnt;
		j = 0;
		for (i = 0; i < aList.length; i ++) {
			if (aList[i][0]) {
				x.options[j].text = aList[i][1];
				x.options[j].value = aList[i][2];
				j ++;
			}
		}
	}
	
	return cnt;
}

function showimage(type)
{
	var platform;
	platform = navigator.platform.substr(0,3);
	if ((navigator.appName == "Microsoft Internet Explorer") && (platform == "Win"))
	{
		switch(type)
		{
		case '0':
			W=W + X_OFFSET_CTRL;
			H=H + Y_OFFSET_CTRL;			
			break;
		case '1':
		case '3':
			W=BaseWidth + X_OFFSET_MD;
			H=BaseHeight + Y_OFFSET_MD;
			STRETCH = "true";
			break;
		case '2':
			W=BaseWidth + X_OFFSET;
			H=BaseHeight + Y_OFFSET;
			STRETCH = "true";
		}

			// The ActiveX plug-in	
		document.write("<object id=\"" + PLUGIN_ID + "\" width=" + W + " height=" + H);
		document.write(" standby=\"Loading plug-in...\" classid=CLSID:" + CLASS_ID);
		document.write(" codebase=\"/" + PLUGIN_NAME + "#version=" + PLUGIN_VER + "\">");
		if(codectype=="mpeg4")
			document.write("<param name=\"Url\" VALUE=\"rtsp://" + location.hostname + "/" + AccessName +"\">");
		else
		{
			document.write("<param name=\"Url\" VALUE=\"http://" + location.host + "/" + AccessName +"\">");
			document.write("<param name=\"ServerModelType\" VALUE=\"0\">");
		}
		
		switch(type)
		{
		case '0':
			document.write("<param name=\"ClientOptions\" VALUE=\"639\">");
			break;
		case '1':
			document.write("<PARAM NAME=\"ControlType\" VALUE=2>");
			document.write("<PARAM NAME=\"EnableMD\" VALUE=\"true\">");
			document.write("<PARAM NAME=\"GetMD\" VALUE=\"/cgi-bin/admin/getmd.cgi\">");
			document.write("<PARAM NAME=\"SetMD\" VALUE=\"/cgi-bin/admin/setmd.cgi\">");
			document.write("<PARAM NAME=\"ClientOptions\" VALUE=\"639\">");	
			break;
		case '2':
			document.write("<PARAM NAME=\"ControlType\" VALUE=0>");
			document.write("<PARAM NAME=\"ClientOptions\" VALUE=\"639\">");	
			break;		
		case '3':		
			document.write("<PARAM NAME=\"ControlType\" VALUE=4>");
			document.write("<PARAM NAME=\"EightTimesInMaskPosSize\" VALUE=\"true\">");
			document.write("<PARAM NAME=\"GetMaskEditParmUrl\" VALUE=\"/cgi-bin/admin/getpm.cgi\">");
			document.write("<PARAM NAME=\"SetMaskEditParmUrl\" VALUE=\"/cgi-bin/admin/setpm.cgi\">");
			document.write("<PARAM NAME=\"ClientOptions\" VALUE=\"639\">");	
		}
		document.write("<param name=\"ViewStream\" VALUE=\"" + streamsource + "\">");
		document.write("<param name=\"VSize\" VALUE=\"CMS\">");
		document.write("<param name=\"Stretch\" VALUE=\"" + STRETCH + "\">");
		document.write("<param name=\"Language\" VALUE=\"" + PLUGIN_LANG + "\">");
		document.write("<param name=\"MP4Conversion\" VALUE=\"true\">");
		document.write(translator('this_is_a_plugin_activex'));
		document.write(translator('if_you_see_this_text_your_browser_does_not_support_or_has_disabled_activex'));
		document.write("<\/object>");
	}
	else if (navigator.appName == "Netscape")
	{
		if (codectype=="mjpeg")
		{
			document.write("<img src=\"http://" + location.host + "/" + AccessName + "\" width=\"" +Width+ "\" height=\"" +Height+"\"/>");
		}
		else
		{
			if(type!=0)
			{
				Width=BaseWidth;
				Height=BaseHeight;
			}
			document.write("<embed SCALE=\"ToFit\" width=\"" + Width + "\" height=\"" + Height + "\"");
			document.write(" type=\"video/quicktime\" qtsrc=\"rtsp://" + location.hostname + "/" + AccessName + "\"");
			document.write(" qtsrcdontusebrowser src=\"/realqt.mov\" autoplay=\"true\" controller=\"true\"\>");
		}
	}
	else
	{
		document.write("Please use Firefox, Mozilla or Netscape<br>");
	}	
}

function openurl(url)
{
	var subWindow = window.open(url, "","width=800, height=600, scrollbars=yes, status=yes");
	subWindow.focus();
}

function countdown()
{
	var board = document.getElementById("progress_bar");
	count --;
	if (count < 0)
	{
		parent.window.location = newlocation;
	}
	else
	{
		board.value = board.value + "|";
		setTimeout("countdown()", intervel);
	}
}

function showNotification(wait_time)
{
	newlocation = "http://" + network_ipaddress + ":" + network_http_port + "/";

	document.getElementById("notification").style.display = "block";
	document.getElementById("notify_location").innerHTML = newlocation;
	count = 100;
	intervel = wait_time * 1000 / count;
	countdown();
}

function SetPluginString(obj)
{
	var i;
	var vMLCodePage = translator("vmlcodepage");
	var vMLFontSize = translator("vmlfontsize");
	var vMLCharSet = translator("vmlcharset");
	var vMLPitch = translator("vmlpitch");
	var vMLSwiss = translator("vmlswiss");
	var vMLFontName = translator("vmlfontname");
	var avMLLangStr = new Array(89);
	
	avMLLangStr[0] = translator("fail_to_connect_server");
	avMLLangStr[1] = translator("zoom");
	avMLLangStr[2] = translator("hide");
	avMLLangStr[3] = translator("media_option");
	avMLLangStr[4] = translator("protocol_option");
	avMLLangStr[5] = translator("the_auto_detection_order_of_transimission_protocol_is_udp_tcp_http");
	avMLLangStr[6] = translator("http_video_only");
	avMLLangStr[7] = translator("tcp");
	avMLLangStr[8] = translator("error");
	avMLLangStr[9] = translator("the_downstream_audio_connection_for_the_current_user_is_not_authorized");
	avMLLangStr[10] = translator("the_media_type_has_been_changed_to_video_only_because_audio_connection");
	avMLLangStr[11] = translator("the_connection_is_closed_because_downstream_audio_connection_is_not_authorized_for_downstream_audio");
	avMLLangStr[12] = translator("the_connection_is_closed_because_server_audio_mode_is_set_to");
	avMLLangStr[13] = translator("the_upstream_channel_is_occupied_please_try_later");
	avMLLangStr[14] = translator("connections_already_exceed_the_limit");
	avMLLangStr[15] = translator("full_duplex");
	avMLLangStr[16] = translator("half_duplex");
	avMLLangStr[17] = translator("talk_only");
	avMLLangStr[18] = translator("listen_only");
	avMLLangStr[19] = translator("audio_disabled");
	avMLLangStr[20] = translator("a_disabled");
	avMLLangStr[21] = translator("audio_only");
	avMLLangStr[22] = translator("no_sound_card");
	avMLLangStr[23] = translator("could_not_initialize_audio_capture_device");
	avMLLangStr[24] = translator("the_upstream_audio_connection_is_not_allowed");
	avMLLangStr[25] = translator("the_downstream_audio_connection_is_not_allowed");
	avMLLangStr[26] = translator("the_media_type_has_been_changed_to_video_only_because_the_audio_mode_is_set_to");
	avMLLangStr[27] = translator("talk");
	avMLLangStr[28] = translator("stop_talk");
	avMLLangStr[29] = translator("the_downstream_audio_connection_is_not_allowed_because_the_media_from_server_contains_no_audio");
	avMLLangStr[30] = translator("the_media_type_has_been_changed_to_video_only_because_the_media_from_server_contains_no_audio");
	avMLLangStr[31] = translator("play");
	avMLLangStr[32] = translator("pause");
	avMLLangStr[33] = translator("resume");
	avMLLangStr[34] = translator("stop");
	avMLLangStr[35] = translator("buffering");
	avMLLangStr[36] = translator("because_the_network_environment_problem_transmission_mode_changes_to_unicast");
	avMLLangStr[37] = translator("because_the_network_environment_problem_transmission_protocol_changes_to_tcp");
	avMLLangStr[38] = translator("please_insert_window_names_on_all_windows");
	avMLLangStr[39] = translator("motion_detection");
	avMLLangStr[40] = translator("connection_is_closed");
	avMLLangStr[41] = translator("save_window_completed");
	avMLLangStr[42] = translator("save_window_failed");
	avMLLangStr[43] = translator("please_close_all_warning_window_first");
	avMLLangStr[44] = translator("because_the_connection_problem_of_network_environment");
	avMLLangStr[45] = translator("warning");
	avMLLangStr[46] = translator("window_name");
	avMLLangStr[47] = translator("sensitivity");
	avMLLangStr[48] = translator("percentage");
	avMLLangStr[49] = translator("new");
	avMLLangStr[50] = translator("save");
	avMLLangStr[51] = translator("disable_digital_zoom");
	avMLLangStr[52] = translator("zoom_factors");
	avMLLangStr[53] = translator("connecting_to");
	avMLLangStr[54] = translator("mute");
	avMLLangStr[55] = translator("_system");
	avMLLangStr[56] = translator("system_error");
	avMLLangStr[57] = translator("can_not_open_registry");
	avMLLangStr[58] = translator("settings_saved");
	avMLLangStr[59] = translator("save_parameter_fail");
	avMLLangStr[60] = translator("disable_audio");
	avMLLangStr[61] = translator("digital_zoom_edit");
	avMLLangStr[62] = translator("play_volume");
	avMLLangStr[63] = translator("mic_volume");
	avMLLangStr[64] = translator("audio_on");
	avMLLangStr[65] = translator("mic_on");
	avMLLangStr[66] = translator("hide_panel");
	avMLLangStr[67] = translator("authenticated_failed");
	avMLLangStr[68] = translator("connect_failed");
	avMLLangStr[69] = translator("x");
	avMLLangStr[70] = translator("y");
	avMLLangStr[71] = translator("width");
	avMLLangStr[72] = translator("height");
	avMLLangStr[73] = translator("private_mask");
	avMLLangStr[74] = translator("path_does_not_exist");
	avMLLangStr[75] = translator("path_cannot_be_empty");
	avMLLangStr[76] = translator("recording_failed");
	avMLLangStr[77] = translator("recording_stop_because_disk_full_or_write_fail");
	
	avMLLangStr[79] = translator("connecting_to");
	avMLLangStr[80] = translator("start_avi_recording");
	avMLLangStr[81] = translator("stop_avi_recording");
	avMLLangStr[82] = translator("start_mp4_recording");
	avMLLangStr[83] = translator("stop_mp4_recording");
	avMLLangStr[84] = translator("mp4_recording_disabled_permission_insufficient");
	avMLLangStr[88] = translator("invalid_prefix_name");
	
	obj.SetGivenLangInfo(vMLCodePage, vMLFontSize, vMLCharSet, vMLPitch, vMLSwiss, vMLFontName);
	for (i = 0; i < avMLLangStr.length; i++)
	obj.SetLangString(i, avMLLangStr[i]);
	obj.Language="update";
}

function CheckEmptyString(input)
{
    if(input.value=="")
    {
	alert(translator("field_cannot_be_empty"));
        input.focus();
        return -1;
    }
    return 0;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

var XMLHttpRequestTranslator = false;
if (window.XMLHttpRequest)
	XMLHttpRequestTranslator = new XMLHttpRequest();
else if (window.ActiveXObject)
	XMLHttpRequestTranslator = new ActiveXObject("Microsoft.XMLHTTP");
XMLHttpRequestTranslator.open("GET", "../include/translator.xml", false);
XMLHttpRequestTranslator.send(null);
xmlDoc=XMLHttpRequestTranslator.responseXML;

lan=getCookie("lan");
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest)
	XMLHttpRequestObject = new XMLHttpRequest();
else if (window.ActiveXObject)
	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
XMLHttpRequestObject.onreadystatechange = receiveparam;

function CountLength(String)
{
    var CurCharLen = 0;
    var MaxCharLen = 40;

    for (var i = 0; i < String.length; i++)
    {
        var AsciiValue = String.charCodeAt(i);
        if (AsciiValue < 128)
        {
            CurCharLen ++;
        }       
        else if (AsciiValue < 256)
        {
            CurCharLen += 2;
        }
        else
        {
            CurCharLen += 3;
        }
    }
    return CurCharLen;
}
